package javacafe.action.vote;

import java.util.List;

import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.dto.vote.VoteDTO;
import javacafe.dto.vote.VotePlayDTO;
import javacafe.serviceimple.VoteServiceImple;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class VoteDeleteAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		ActionForward actfoward = new ActionForward();		
		VoteServiceImple service = VoteServiceImple.getInstance();		
		
		VoteDTO dto = new VoteDTO();
		VotePlayDTO vpdto = new VotePlayDTO();
		
		String vote_no = request.getParameter("seq");
		dto.setVote_no(Integer.parseInt(vote_no));
		vpdto.setVote_no(Integer.parseInt(vote_no));
		
		service.deleteVotePlay(vpdto);
		service.deleteVote(dto);
				
		List<VoteDTO> list = null;
		
		list = service.getVoteList();
		
		request.setAttribute("list",list);
		
		actfoward.setUrl("votelistform");
		return actfoward;
	}

}
